<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../static/plugins/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
            
<blockquote class="layui-elem-quote">目前Layui中的日期组件还是layDate 1.1的改良版，它后续将会进行一次重写。</blockquote>
      
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>顺便列举几个常用例子</legend>
</fieldset>
<div class="layui-inline">
  <input class="layui-input" placeholder="自定义日期格式" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
</div>
<div class="layui-inline">
  <input class="layui-input" placeholder="开启节日" onclick="layui.laydate({elem: this, festival: true})">
</div>
<div class="layui-inline">
  <input class="layui-input" placeholder="只能选昨天到明天" onclick="layui.laydate({elem: this, min: laydate.now(-1), max: laydate.now(+1)})">
</div>
<div class="layui-form-pane" style="margin-top: 15px;">
  <div class="layui-form-item">
    <label class="layui-form-label">范围选择</label>
    <div class="layui-input-inline">
      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
    </div>
    <div class="layui-input-inline">
      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
    </div>
  </div>
</div>               
          
<script src="../static/plugins/layui/layui.js" ></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  var start = {
    min: laydate.now()
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      end.min = datas; //开始日选好后，重置结束日的最小日期
      end.start = datas //将结束日的初始值设定为开始日
    }
  };
  
  var end = {
    min: laydate.now()
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      start.max = datas; //结束日选好后，重置开始日的最大日期
    }
  };
  
  document.getElementById('LAY_demorange_s').onclick = function(){
    start.elem = this;
    laydate(start);
  }
  document.getElementById('LAY_demorange_e').onclick = function(){
    end.elem = this
    laydate(end);
  }
  
});
</script>

</body>
</html>